package com.xit.hitmouse.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	public static final String CREATE_SCORE = "create table score ("
			+ "id integer primary key autoincrement, "
			+ "author text, "
			+ "score integer)";

	public static final String CREATE_USER = "create table user ("
			+ "id integer primary key autoincrement, "
			+ "username text, "
			+ "password text, "
			+ "money integer)";
	public static final String CREATE_Kill = "create table kill ("
			+ "id integer primary key autoincrement, "
			+ "count  integer,"
			+ "run    integer,"
			+ "userid integer,"
			+ "time  text,"
			+"FOREIGN KEY(serid) REFERENCES user(id))";
	public static final String CREATE_Killitem = "create table killitem ("
			+ "id integer primary key autoincrement, "
			+ "type   integer, "
			+ "count  integer,"
			+ "type2  integer,"
			+ "killid  integer," +
			"FOREIGN KEY(killid) REFERENCES kill(id))";
			private Context mContext;

	public DBHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		mContext = context;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_USER);
		db.execSQL(CREATE_SCORE);
		db.execSQL(CREATE_Kill);
		db.execSQL(CREATE_Killitem);


	}


		@Override
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
			// 在这里实现数据库升级的逻辑
			if (oldVersion < newVersion) {
				// 如果需要升级数据库结构，可以在这里执行相应的操作
				// 例如：删除旧表、创建新表或者修改表结构
				db.execSQL(CREATE_USER);
			}
		}

}
